#include "database_home.h"
#include "ui_database_home.h"
#include "login.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "fhmainwindow.h"
#include "ui_fhmainwindow.h"
#include "yrmainwindow.h"
#include "ui_yrmainwindow.h"

//static QString windowIndex="";
QString database_home::windowIndex = "";
database_home::database_home(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::database_home)
{
    // 设置窗口标志，禁用最大化按钮
    setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
    ui->setupUi(this);
    logined = false;
    //connect(ui->home_login,SIGNAL(clicked()),this,SLOT(on_home_login_clicked()));
}

database_home::~database_home()
{
    delete ui;
}

void database_home::on_home_login_clicked()
{
    this->close();
    login *my_login = new login();
    my_login->setWindowTitle("森林-城镇交界域典型建筑材料的引燃和燃烧危险性数据库");
    my_login->show();
}

void database_home::setValue(bool value , QString index)
{
    logined = value;
    windowIndex = index;
    qDebug()<< "logined:" <<logined << "index:" << windowIndex;
}

void database_home::on_pushButton_6_clicked()
{
    if(logined){
        this->close();
        if (windowIndex == "yr") {
            //MainWindow *w = new MainWindow();
            YRMainWindow *w = new YRMainWindow();
            w->setWindowTitle("森林-城镇交界域典型建筑材料的引燃和燃烧危险性数据库--辐射引燃危险性和燃烧特性数据库");
            w->show();
        }else if (windowIndex == "fh") {
            FHMainWindow *fhw = new FHMainWindow();
            fhw->setWindowTitle(tr("森林-城镇交界域典型建筑材料的引燃和燃烧危险性数据库--飞火引燃危险性数据库"));
            fhw->show();
        }

    }else{
        QMessageBox msgBox;
        msgBox.setText(tr("未检测到用户登录信息，请先登录！"));
        msgBox.exec();
    }
}
